{extend name="admin@publics/base"/}
{block name="title"}节点管理{/block}
{block name="body"}
<script>
//页面变量
_PAGE['adminAuthRule'] = {
};
/*==========控制器==========*/
Ext.define('admin.auth_rule.CURDViewController', {
	extend: 'Tg.tx.CURDViewController',
	alias: 'controller._adminAuthRuleController',
});
/*==========模型==========*/
Ext.define('admin.auth_rule.CURDViewModel', {
	extend: 'Tg.tx.CURDViewModel',
	alias: 'viewmodel._adminAuthRuleViewModel',
    //Data
    data:{
    	//权限
        _Auth:{
        	index	: {if condition="_CheckAuth('admin/AuthRule/index')"}true{else/}false{/if},
        	add		: {if condition="_CheckAuth('admin/AuthRule/add')"}true{else/}false{/if},
        	edit	: {if condition="_CheckAuth('admin/AuthRule/edit')"}true{else/}false{/if},
        	del		: {if condition="_CheckAuth('admin/AuthRule/del')"}true{else/}false{/if},
        },
        _Url:{
        	index	: _PATH['site']+'/admin/auth_rule/index',
        	add		: _PATH['site']+'/admin/auth_rule/add',
        	edit	: _PATH['site']+'/admin/auth_rule/edit',
        	del		: _PATH['site']+'/admin/auth_rule/del',
        },
        //操作视图
        _Ext:{
        	index	: 'admin.auth_rule.index',
        	serch	: 'admin.auth_rule.serch',
        	add		: 'admin.auth_rule.updata',
        	edit	: 'admin.auth_rule.updata',
        	del		: 'admin.auth_rule.del',
        },
		_Pk:'id',
		_PPk:'p_id',
    },
    //Store
	stores: {
		_MainStore: {
			type: 'tree',
			sorters: [{property: 'id',direction: 'desc'}],
			remoteSort: true,
			remoteFilter:true,
			expanded:true,
			proxy: {
				type: 'ajax',
				api: {read: _PATH['site']+'/admin/auth_rule/index'},
				actionMethods:{read: "POST"},
				reader: {type: 'json',root: 'children'}
			},
		}
	},
});
/*==========视图==========*/
//列表
Ext.define('admin.auth_rule.index', {
	extend: 'Tg.tx.CURDList',
	alias: 'widget.admin_AuthRule_index',
	requires: [
		'admin.auth_rule.CURDViewController',
		'admin.auth_rule.CURDViewModel',
	],
	controller: '_adminAuthRuleController',
	viewModel: '_adminAuthRuleViewModel',
    _TbarLBefore:[
        {xtype: 'label',text: '节点管理',itemId:'_Tit',style: 'font-size:16px; padding-right:10px;margin-right: 10px;border-right: dotted 1px #ccc;'}
    ],
    items:[
		{
			xtype:'CURDListTree',
			bind:{store:'{_MainStore}'},
			columns:[
        		{xtype:"actioncolumn",header:"更新",width: 50,iconCls:'tf tf-edit',align:'center',locked: true,handler: '_ColumnEdit',bind:{hidden:'{!_Auth.edit}'}},
				{xtype:"actioncolumn",header:"删除",width: 50,iconCls:'tf tf-del',align:'center',locked: true,handler: '_ColumnDel',bind:{hidden:'{!_Auth.del}'}},
				{dataIndex:'id', header :'主键', width :60,locked: true, hidden:false, },
				{dataIndex:'title',xtype : 'treecolumn', header :'标题',width :220, hidden:false },
				{dataIndex:'name', header :'路由', width :150, hidden:false },
				{dataIndex:'sort', header :'排序', width :60, hidden:false },
				{dataIndex:'identifying', header :'标志', width :200, hidden:false, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {return _Res_Val(_ExtendList,'extend', value);}},
				{dataIndex:'hide', header :'隐藏', width :60, hidden:false, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {return _Res_Val(_Dictionary,'sys_true', value);}},
				{dataIndex:'status', header :'状态', width :60, hidden:false, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {return _Res_Val(_Dictionary,'sys_status', value);}},
				{dataIndex:'create_time', header :'创建时间', width :110, hidden:true },
				{dataIndex:'update_time', header :'更新时间', width :110, hidden:true },
			],
		}
	],
});



//操作 
Ext.define('admin.auth_rule.updata', {
	extend: 'Tg.tx.Window',
	alias: 'widget.admin_AuthRule_updata',
	requires: [
		'admin.auth_rule.CURDViewController',
		'admin.auth_rule.CURDViewModel',
	],
	controller: '_adminAuthRuleController',
	viewModel: '_adminAuthRuleViewModel',
    title:'节点 - 操作',
    items:{
    	xtype:'CURDForm',
        items:[
			{items: [
				{xtype:'combobox', fieldLabel: '所属', name: 'identifying', itemId: 'identifying', cls: '', columnWidth: 1, height: 30, readOnly: false, emptyText:'请选择...', editable:false, displayField:'text', valueField: 'value', store:{fields:['text','value'],data:_ExtendList['extend']}},
			]},
			{items: [
				{xtype:'treepicker', fieldLabel: '上级', name: 'p_id', itemId: 'p_id', cls: '', columnWidth: 1, height: 30, readOnly: false, emptyText:'请输入...', editable:false,displayField: "text",valueField: "id",rootVisible:true,store:Ext.create('Ext.data.TreeStore',{autoLoad: true,expanded:true,proxy : {type : 'ajax',url : _PATH['site']+'/admin/api/rule_lists'}})},
			]},
			{items: [
				{xtype:'textfield', fieldLabel: '标题', name: 'title', itemId: 'title', cls: '', columnWidth: .5, height: 30, readOnly: false, emptyText:'请输入...'},
				{xtype:'textfield', fieldLabel: '路由', name: 'name', itemId: 'name', cls: '', columnWidth: .5, height: 30, readOnly: false, emptyText:'请输入...'},
			]},
			{items: [
				{xtype:'AuthRule_IconCombo', fieldLabel: '图标', name: 'icon', itemId: 'icon', cls: '', columnWidth: .5, height: 30, readOnly: false, emptyText:'请选择...', editable:true, displayField:'text', valueField: 'value', store:{fields:['text','value'],autoLoad:true,proxy: {type: 'ajax',url:_PATH['site']+'/admin/api/icon_lists?verify_code={:_AutoCodeUrl('admin/AuthRule/index')}'}}},
				{xtype:'numberfield', fieldLabel: '排序', name: 'sort', itemId: 'sort', cls: '', columnWidth: .5, height: 30, readOnly: false, minValue:'0', maxValue:'999999', allowDecimals:false, decimalSeparator:'.'},
			]},
			{items: [
				{xtype:'combobox', fieldLabel: '隐藏', name: 'hide', itemId: 'hide', cls: '', columnWidth: .5, height: 30, readOnly: false, emptyText:'请选择...', editable:false, displayField:'text', valueField: 'value', store:{fields:['text','value'],data:_Dictionary['sys_true']}},
				{xtype:'combobox', fieldLabel: '状态', name: 'status', itemId: 'status', cls: '', columnWidth: .5, height: 30, readOnly: false, emptyText:'请选择', editable:false, displayField:'text', valueField: 'value', store:{fields:['text','value'],data:_Dictionary['sys_status']}},
			]},
			{items: [
				{xtype:'textarea', fieldLabel: '附加参数', name: 'extend', itemId: 'extend', cls: '', columnWidth: 1, height: 80, readOnly: false, preventScrollbars:true, emptyText:'请输入...'},
			]},
			{items: [
				{xtype:'textarea', fieldLabel: '附加规则', name: 'condition', itemId: 'condition', cls: '', columnWidth: 1, height: 80, readOnly: false, preventScrollbars:true, emptyText:'请输入...'},
			]},
			{xtype:'hiddenfield', fieldLabel: '主键', name: 'id', itemId: 'id', cls: '', columnWidth: 1, height: 30, readOnly: false},
        ]
    }
});



//实例化
Ext.application({
	name: 'admin',
	extend: 'Ext.app.Application',
	autoCreateViewport: 'admin.auth_rule.index'
});


Ext.define('admin.auth_rule.IconCombo', {
  extend: 'Ext.form.field.ComboBox',
  alias: 'widget.AuthRule_IconCombo',
  initComponent: function() {
    Ext.apply(this, {
      fieldLabel: '选择图标',
      queryMode: 'local',
      displayField : 'iconCls',
      valueField : 'iconCls',
      tpl: Ext.create('Ext.XTemplate', '<table class="IconCombo"><tr><tpl for="."><td class="x-boundlist-item" data-qtip="{iconCls}"><i class="{iconCls}" ></i></td><tpl if="xindex % 5 === 0"></tr><tr></tpl></tpl></tr></table>'),
      displayTpl: Ext.create('Ext.XTemplate', '<tpl for=".">', '{iconCls}', '</tpl>')
    });
    this.callParent();
  }
});
</script>
<style>
.IconCombo{ width:100%}
.IconCombo .x-boundlist-item{padding:0; width:20%; text-align:center}
.IconCombo .x-boundlist-item i{font-size:22px;}
</style>
{/block}
